package com.taxsystem.yehao.jsonParser;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import com.taxsystem.yehao.tool.UrlPost;

public class CalendarJsonParser {
	public static List<HashMap<String,Object>>parseTaxType(String url,Map<String,Object> params) {
		List<HashMap<String,Object>>retList = new ArrayList<HashMap<String,Object>>();
		try {
			JSONObject jsonObject = UrlPost.getJsonObject(url, params);
			jsonObject=jsonObject.getJSONObject("data");
			JSONArray jsonArray = jsonObject.getJSONArray("typeList");
			for(int i=0;i<jsonArray.length();i++) {
				JSONObject TaxTypeJsonObject = jsonArray.getJSONObject(i);
				 HashMap<String,Object> map = new HashMap<String,Object>();
				 map.put("taxTypeId", TaxTypeJsonObject.getString("taxTypeId"));
				 map.put("taxTypeName", TaxTypeJsonObject.getString("taxTypeName"));
				 retList.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return retList;
	}
	public static List<HashMap<String,Object>>parseCalendar(String url,Map<String,Object> params) {
		List<HashMap<String,Object>>retList = new ArrayList<HashMap<String,Object>>();
		try {
			JSONObject jsonObject = UrlPost.getJsonObject(url, params);
			jsonObject = jsonObject.getJSONObject("data");
			JSONArray jsonArray=jsonObject.getJSONArray("calendar");
			for(int i=0;i<jsonArray.length();i++) {
				JSONObject CalendarJsonObject = jsonArray.getJSONObject(i);
				 HashMap<String,Object> map = new HashMap<String,Object>();
				 map.put("taxCalId", CalendarJsonObject.getString("taxCalId"));
				 map.put("branchId", CalendarJsonObject.getString("branchId"));
				 map.put("taxTypeId", CalendarJsonObject.getString("taxTypeId"));
				 map.put("year", CalendarJsonObject.getString("year"));
				 map.put("month", CalendarJsonObject.getString("month"));
				 map.put("fromDay", CalendarJsonObject.getString("fromDay"));
				 map.put("toDay", CalendarJsonObject.getString("toDay"));
				 map.put("remark", CalendarJsonObject.getString("remark"));
				 retList.add(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return retList;
	}
}
